﻿@model ProggyFileUploader
@{
    // get name
    var fileName = Model.PropertyNameStart + ".PostedFile";

    // get id
    var fileId = Model.PropertyNameStart + "_PostedFile";

    // get desc
    var descName = Model.PropertyNameStart + ".Description";
    var descId = Model.PropertyNameStart + "_Description";

    // get filename
    var fileNameName = Model.PropertyNameStart + ".FileName";
    var fileNameId = Model.PropertyNameStart + "_FileName";

    // get mime
    var fileMimeName = Model.PropertyNameStart + ".MimeType";
    var fileMimeId = Model.PropertyNameStart + "_MimeType";

    // get filepath
    var filePathName = Model.PropertyNameStart + ".FilePath";
    var filePathId = Model.PropertyNameStart + "_FilePath";

    // get serverpath
    var serverPathName = Model.PropertyNameStart + ".ServerFilePath";
    var serverPathId = Model.PropertyNameStart + "_ServerFilePath";
}
<input type="hidden" name="@fileNameName" id="@fileNameId" value="@Model.FileName" />
<input type="hidden" name="@fileMimeName" id="@fileMimeId" value="@Model.MimeType" />
<input type="hidden" name="@filePathName" id="@filePathId" value="@Model.FilePath" />
<input type="hidden" name="@serverPathName" id="@serverPathId" value="@Model.ServerFilePath" />
@if (string.IsNullOrEmpty(Model.FileName))
{ 
    <p>
        <label>
            Current file</label>No file uploaded yet</p>
}
else
{
    <p>
        <label>
            Current file</label><a target="_blank" href="@Url.Content(Model.FilePath)">@Model.FileName.Substring(0, Model.FileName.Length < 40 ? Model.FileName.Length : 40)</a>
        &nbsp;<span class="italic">...of type <span class="strong">@Model.MimeType</span></span><br />
    </p>
    <p style="margin-left: 1em;">
        <span class="red italic">If you want to change or update the file, use the uploader
            below. If you upload a file with the same name as the current saved file, it WILL
            OVERWRITE.</span></p>
    
}
<p>
    <label for="@fileName">
        File</label><input name="@fileName" id="@fileId" type="file" /></p>
<div style="margin-left: 1em; color: #999">
    <h5 style="margin-bottom: 1em;">
        <label for="@descName">
            Description</label></h5>
    <textarea name="@descName" id="@descId" class="proggy-textarea proggy-textarea-large">@Model.Description</textarea></p>
</div>
